export const initList = [
    {
        id: 0,
        timeMap: '1540612312',
    },
    {
        id: 1,
        timeMap: '1580612322',
    },
    {
        id: 2,
        timeMap: '1580712322',
    },
    {
        id: 3,
        timeMap: '1589743122',
    },
];

export default {
    'GET /api/unitTest/list': initList,
    'POST /api/unitTest/list': (req, res) => {
        const item = {
            id: initList.length,
            ...req.body,
        };
        initList.push(item);
        const timer = setTimeout(() => {
            res.send([...initList]);
            clearTimeout(timer);
        }, 2000);
    },
    'Delete /api/unitTest/list': (req, res) => {
        const { id } = req.body;
        initList.forEach((item, index) => {
            if (item.id * 1 === id * 1) {
                initList.splice(index, 1);
            }
        });
        const timer = setTimeout(() => {
            res.send([...initList]);
            clearTimeout(timer);
        }, 2000);
    },
    'Put /api/unitTest/list': (req, res) => {
        const item = req.body;
        initList.push(item);
        const timer = setTimeout(() => {
            res.send([...initList]);
            clearTimeout(timer);
        }, 2000);
    },
};
